$(function(){
	$(".button").click(function(){
		window.location.href="refunddetail.html"
	})
	var id = window.location.search.substr(4);
	console.log(id)
	$.ajax({
		type:"get",
		url:baseUrl+'hsent-xxyl-user/orderRefund/initOrderRefund',
		data:{
			orderId:id
		},
		success:function(res){
			console.log(res);

			var data = {
					detailOrder:res.data,
					picUrl:picUrl
			};
			var listCon = template('test', data);
			document.getElementById('midbox').innerHTML = listCon;
		}
	})
})
function tijiaos(item){
	var reasonArr=[];
	console.log(item);
	console.log($('.refundchoose input'));
	$('.refundchoose input').each(function(){
		console.log($(this)[0].checked);
		console.log($(this).prev().text());
		if($(this)[0].checked){
			reasonArr.push($(this).prev().text())
		}
	});
	if($('#write').val()){
		reasonArr.push($('#write').val())
	}
	console.log(reasonArr);
	var arr = reasonArr.toString();
	console.log(arr);
	$.ajax({
		type:'get',
		url:baseUrl+'hsent-xxyl-user/orderRefund/insertOrderRefund',
		data:{
				shopId:item.shopId,        //店铺编号
				orderId:item.id,        //订单编号
				realPay :item.payAmount,        //订单实付金额
				refundAmount:item.refundAmout,        //退款金额
				 refundRatio :item.refundRatio,        //退款比例
				 refundReason :arr,        //退款原因
				refundHscouponAmount:item.ptCouponsDiscount,        // 抵扣券金额
		},
		success:function(res){
			console.log(res);
			if(res.status==1){
				alert('退款成功!');
				window.location.href='refunddetail.html?id='+item.id;
			}else{
				alert('失败,请重试!');
			}
		}
	})
}
